package project1;

import java.io.IOException;
import java.nio.charset.*;
import java.nio.file.*;
import java.util.ArrayList;
import java.util.List;

/**
 *  @author Andrew O'Connor
 *  COSC 603
 *  Project 1
 */
public class ReadTextFile {

    private Charset encoding;

    public ReadTextFile(Charset _encoding) {
        encoding = _encoding;
    }

    /**
     *
     * @param _fileName file to be read from
     * @return list of lines read from file
     */
    public List<String> readSmallTextFile(String _fileName) {
        try {
            Path path = Paths.get(_fileName);
            return Files.readAllLines(path, encoding);
        } catch (IOException e) {
            System.out.println("error: can't open " + _fileName);
        }
        return new ArrayList<String>();
    }
}
